/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ucm;
import java.sql.*;
import model.UCModel;

public class UCRegister extends UCModel{

    public UCRegister(String text, String text0) {
        throw new UnsupportedOperationException("Not yet implemented");
    }
    public boolean run() {
        if (DBconnect == null) {
            DBconnect = new DBConnect();
        }

        try {
            Statement myst = DBconnect.getConnection().createStatement(ResultSet.CONCUR_UPDATABLE,
                    ResultSet.CONCUR_UPDATABLE);
            ResultSet reset;
            reset = myst.executeQuery("select * from user where name = '" + username + "'");
            if (reset.next()) {
                System.out.println("User name exist");
                return false;
            }
            myst.executeUpdate("insert into  usersinfomation(name, password) values('" + username + "', '" + password + "')");
            return true;
        } catch (Exception e) {
            System.out.println(e);
            return false;
        }
    }
}

